home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / gfx / misc / phoon.lha / fullmoon.c < prev    next >
C/C++ Source or Header  |  1992-09-01  |  2KB  |  69 lines

  1. /*
  2. ** Copyright (C) 1988 by Jef Poskanzer and Craig Leres.
  3. **
  4. ** Permission to use, copy, modify, and distribute this software and its
  5. ** documentation for any purpose and without fee is hereby granted, provided
  6. ** that the above copyright notice appear in all copies and that both that
  7. ** copyright notice and this permission notice appear in supporting
  8. ** documentation.  This software is provided "as is" without express or
  9. ** implied warranty.
  10. */
  11.  
  12. #define CENTER_X ((fm_w / 2) - 1 + *cx)
  13. #define CENTER_Y ((fm_h * 645 / 1280) + *cy)
  14. #define RADIUS_X ((378 * fm_w / 1600) + 1 + *rx)
  15. #define RADIUS_Y ((378 * fm_h / 1280) + 1 + *ry)
  16.  
  17. checkbitmapsize(w, h, fm_w, fm_h, cx, cy, rx, ry)
  18.     int *w, *h;
  19.         int fm_w, fm_h;
  20.     int *cx, *cy, *rx, *ry;
  21. {
  22.     int minw, minh;
  23.  
  24.     minw = ((CENTER_X + RADIUS_X + 7)/8 - (CENTER_X - RADIUS_X)/8) * 8;
  25.     minh = 2*RADIUS_Y;
  26.     if (*w < minw) *w = minw;
  27.     if (*h < minh) *h = minh;
  28.  
  29.     if (*w > fm_w)  *w = fm_w;
  30.     if (*h > fm_h) *h = fm_h;
  31. }
  32.  
  33. getbitmap(w, h, fm_w, fm_h, bits_p, cx, cy, rx, ry)
  34.     int w, h, fm_w, fm_h;
  35.     char **bits_p;
  36.     int *cx, *cy, *rx, *ry;
  37. {
  38.     int bx, by;    /* origin of fullmoon bitmap in display coordinates */
  39.     int fl, dl;    /* length of scan line in bytes of fullmoon, display */
  40.     int fb;     /* useable bytes of image */
  41.     int y;        /* Current position in display bitmap */
  42.     char *fbp, *dbp;    /* Pointers to current bitmap position */
  43.  
  44.     dl = ((w + 15) / 16) * 2;
  45.     fl = ((fm_w + 15) / 16) * 2;
  46.     fb = (fm_w + 7) / 8;
  47.  
  48.     bx = (dl-fb)/2;
  49.     by = (h-fm_h)/2;
  50.  
  51.     *cx = CENTER_X + bx * 8;
  52.     *cy = CENTER_Y + by;
  53.     *rx = RADIUS_X;
  54.     *ry = RADIUS_Y;
  55.  
  56.     if (w == fm_w) {
  57.       *bits_p = *bits_p - by * fl;
  58.       return;
  59.     }
  60.     dbp = *bits_p;
  61.     for (y=0; y<h; y++) {
  62.         fbp = *bits_p + (y-by)*fl - bx;
  63.         bcopy(fbp,dbp,dl);
  64.         dbp += dl;
  65.     }
  66. }
  67.  
  68.  
  69.